-
-
Notifications
You must be signed in to change notification settings - Fork 261
[Collapsible] Rework CSS transitions #1549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
e95ace8 to
c677588
Compare
docs/src/styles.css
Outdated
| [data-demo]:not([data-demo='tailwind']) * { | ||
| all: revert-layer; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tailwind v4 preflight contains:
[hidden]:where(:not([hidden="until-found"])) {
display: none !important;
}which interferes when we need to set display: block while the panel is still hidden to measure it's rendered size before the browser actually renders the change
Setting !important in our inline styles should be enough as long as they are removed accordingly
deab71c to
9d2d1fb
Compare
d33ec17 to
277a85d
Compare
277a85d to
00f99b8
Compare
6febffa to
5c9a159
Compare
|
Continues in #1601 |
Demo: https://deploy-preview-1549--base-ui.netlify.app/experiments/collapsible/transition
Exploring a solution for both #1334 and #1458
Findings:
Tailwind v4 defaults started applying
display: none !importanton[hidden]which we must override in order to measure the nodeNew gotcha: when transitioning multiple properties e.g.solved and not a limitation anymore ✌️opacityandheighttogether,transition-propertymust list individual properties (transition-property: height, opacity) instead ofallUsed an
AbortControllerto cancel pending unmounts if the open state changes back to open before the pending unmount actually occurs (which is after the duration of the exit transition). I wonder if CSS animations can be made interruptible like transitions with AbortController.Using
element.style.removeProperty('height')leads to huge improvements in the timing/consistency vselement.style.height = ''(or even'0px')There is a weird edge case when
keepMounted={false}and the panel is initially closed, when it opens for the first time and only the first timedata-starting-styleis missing or off by a frame and it needs to be manually set:element.setAttribute('data-starting-style', '')I have followed (at least) the PR section of the contributing guide.